package heven.holt.eyepetizer

import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.annotation.SuppressLint
import com.xiaojinzi.component.anno.RouterAnno
import com.xiaojinzi.component.impl.*
import com.xiaojinzi.component.support.CallbackAdapter
import heven.holt.eyepetizer.databinding.EyeActivitySplashBinding
import heven.holt.library.base.BaseActivity

@SuppressLint("CustomSplashScreen")
@RouterAnno(
    path = "eye_splash",
    desc = "this is eye splash activity"
)
class EyeSplashActivity : BaseActivity<EyeActivitySplashBinding>() {
    override fun bindViewBinding(): EyeActivitySplashBinding =
        EyeActivitySplashBinding.inflate(layoutInflater)

    override fun initView() {
    }

    override fun initData() {
    }

    override fun onStart() {
        super.onStart()
        binding.ivSlogan.animate()
            .alpha(1f)
            .setDuration(3000L)
            .setListener(null)
        binding.ivSplashPicture.animate()
            .scaleX(1.05f)
            .scaleY(1.05f)
            .setDuration(3000L)
            .setListener(object : AnimatorListenerAdapter() {
                override fun onAnimationEnd(animation: Animator?) {
                    Router.with(this@EyeSplashActivity)
                        .host("eyepetizer").path("eye_main")
                        .forward(onSuccess())
                }
            })
    }

    fun onSuccess(): Callback = object : CallbackAdapter() {
        override fun onSuccess(result: RouterResult) {
            finish()
        }
    }
}